<style type="text/css">
body{background:#eee}
.storelogo img{width:3.2rem;height:3.2rem}
.merchgroup .store-star {padding:0.1rem 0 0.2rem 0;font-size:0.55rem;line-height:1rem}
.merchgroup .store-star img{height:0.66rem}
.star-on,.star-off{position:absolute;top:1rem;left:0;overflow:hidden}
.star-rate {margin-left:3.6rem}
.store-distance{float:right;color:#999}
.store-moneylimit{font-size:0.55rem}
.weui_cell_hd {
    padding: 0.6rem;
	padding-left: 0;
}
.weui_cells_text {padding:0 10px;padding-top:10px}
p {
    margin: 0 0 2px;
}
.fui-number .minus:before, .fui-number .plus:before {
	border-left: 0 solid #d9d9d9;
}
.fui-number .minus:after, .fui-number .plus:after {
	border-right: 0 solid #d9d9d9;
}
.fui-number:before {
	border-top: 0 solid #d9d9d9;
}
.fui-number:after {border-top: 0 solid #d9d9d9;}
.fui-number .num {
	color:#666;
}
.fui-number .num {
	color:#666;
}
.fui-number.small {
	height: 1.2rem;
	width: 3.6rem;
	line-height: 1.2rem;
}
.fui-number .minus, .fui-number .plus {
	z-index:0;
}
.fui-number.small .minus{
	color: {{main.syscolor || '#63BE72'}};
	padding-top:1px;
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
 .fui-number.small .plus {
	color: #fff;
	padding-top:1px;
	background: {{main.syscolor || '#63BE72'}};
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
.arrow-top {
  width: 0;   
  height: 0;   
  border-left: 10px solid transparent; 
  border-right: 10px solid transparent;
  border-bottom: 10px solid #000; 
  font-size: 0;  
  line-height: 0;
  margin-left:1.3rem
}
</style>
<div class="fui-page order-create-page fui-page-current" ng-if="pagedata.op == 'main'">
	 <div class="fui-header">
		<div class="fui-header-left" ng-click="goback()">
            <a class="back"></a>
        </div>
		<div class="title">确认服务</div>
		<div class="fui-header-right"></div>
	</div>
	<div class="fui-content">
		<div class="weui_cells weui_cells_form">
				<div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">联系人</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ng-model="pagedata.post.username" class="weui_input" type="text" placeholder="请输入联系人">
                </div>
                </div>
				<div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">联系电话</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ng-model="pagedata.post.mobile" value="{{pagedata.post.mobile}}" class="weui_input" type="text" placeholder="请输入电话">
                </div>
                </div>
        </div>
		<div class="weui_cells">
		<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">维修类目</label></div>
                <div class="weui_cell_hd weui_cell_primary">
                    <select class="weui_select weui_input" name="cateid2" ng-model="pagedata.post.groupid">
                        <option ng-repeat="q in pagedata.groups" value="{{q.id}}">{{q.title}}</option>
					</select>
                </div>
        </div>
		<div class="weui_cell">
				<div class="weui_cell_hd"><label class="weui_label">维修项目</label></div>
                <div class="weui_cell_hd weui_cell_primary">
                   <select class="weui_select" name="cateid2" ng-change="pagedata.upprice()" ng-model="pagedata.post.pid">
                        <option ng-repeat="q in pagedata.groups[pagedata.post.groupid].list" value="{{q.id}}">{{q.title}}</option>
                  </select>
                </div>
        </div>
		<div class="weui_cells_title">简单故障描述</div>
		<div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" style="background:#f2f2f2">
					<textarea ng-model="pagedata.post.remark" class="weui_textarea" style="background:#f2f2f2" placeholder="输入故障描述" rows="3"></textarea>
                </div>
        </div>
		<div class="weui_cells_title">故障拍照</div>
		<div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
					<div class="weui_uploader">
                        <div class="weui_uploader_bd" style="margin-bottom:0">
                            <ul class="weui_uploader_files">
                                <li ng-repeat="p in pagedata.post.images" class="weui_uploader_file" style="background-image:url('{{tomedia(p)}}')">
									<div class="upbtn" >
										<a style="color:#f60" href="javascript:;" ng-click="pagedata.post.images.splice($index-1,0,p);pagedata.post.images.splice($index+1,1)">上移</a>
										<a style="color:#f60" href="javascript:;" ng-click="pagedata.post.images.splice($index,1)">删除</a>
									</div>
								</li>
                            </ul>
                            <div class="weui_uploader_input_wrp" href="javascript:;" ng-click="images(pagedata.post,'images')"></div>
                        </div>
                    </div>
				</div>
        </div>
		<div class="weui_cells_title">故障视频</div>
		<div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" style="">
					<ul class="weui_uploader_files" ng-if="pagedata.post.video">
						<li class="weui_uploader_file" style="width: 188px;height: 100px;background: #333;">
							<video ng-src="{{tomedia(pagedata.post.video)}}" poster="{{tomedia(pagedata.post.thumb)}}" height="100" width="100%" controls="" x5-playsinline="" playsinline="" webkit-playsinline="" poster="" preload="auto"></video>
						 </li>
					</ul>
					<div class="weui_uploader_input_wrp">
						<input class="weui_uploader_input" ng-click="choose_source(pagedata.post,['video','thumb'],'video')"  multiple="">
					</div>
				</div>
        </div>
		</div>
		<div ng-include="sys_html('common/_diyform',true)"></div>
		<div ng-if="false" class="weui_cells_title">服务类型</div>
		<div ng-if="false" class="weui_cells weui_cells_radio2">
			<div class="weui_cell">
				<label ng-if="pagedata.post.order_types.indexOf(';0;')>=0" class="weui_cell weui_check_label">
					<div class="weui_cell_hd">
						<input type="radio" class="weui_check" value="0" ng-model="pagedata.post.type" ng-change="pagedata.upprice()" ng-checked="pagedata.post.type==0">
						<span class="weui_icon_checked"></span>
					</div>
					<div class="weui_cell_bd weui_cell_primary" style="padding-left:0">
						产品寄修
					</div>
				</label>
				<label ng-if="pagedata.post.order_types.indexOf(';1;')>=0" class="weui_cell weui_check_label">
					<div class="weui_cell_hd">
						<input type="radio" class="weui_check" value="1" ng-model="pagedata.post.type" ng-change="pagedata.upprice()" ng-checked="pagedata.post.type==1">
						<span class="weui_icon_checked"></span>
					</div>
					<div class="weui_cell_bd weui_cell_primary" style="padding-left:0">
						到店维修
					</div>
				</label>
			 </div>
		 </div>
		 <div ng-show="pagedata.post.type==1" class="fui-list-group"  id="carrierInfo" style="margin: 0 0 0.5rem">
					<div ng-if="!pagedata.merch" class="fui-list" href="javascript:;" ng-click="pagedata.showstores=true">
						<div ng-if="pagedata.selectstore.id" class="fui-list-media">
							<i class="icon icon-map"></i>
						</div>
						<div ng-if="pagedata.selectstore.id" class="fui-list-inner">
							<div class="subtitle" >
								<span style="overflow: hidden;display: inline-block;">门店：</span>
								<span class='realname'>{{pagedata.selectstore.title}}</span>
								
							</div>
							<div class="text address">地址：<span style="color:{{main.syscolor || 'red'}}">{{pagedata.selectstore.pcd.city}}</span>({{pagedata.selectstore.pcd.district}} {{pagedata.selectstore.pcd.street}} {{pagedata.selectstore.address}})</div>
						</div>
						<div ng-if="pagedata.selectstore.id" class="fui-list-angle">
							<div class="angle"></div>
						</div>
						<div ng-if="!pagedata.selectstore.id" class="fui-list-inner">
							<div class="text no-address" style="width:8rem"><i class="icon icon-ruzhuchenggongdapx"></i> 选择门店</div>
						</div>
					</div>
					<div ng-if="pagedata.selectstore.is_work_time==1" class="fui-list" ng-click="pagedata.gotoshowstoretime()">
						<div class="fui-list-media" style="width:100px"><i class="icon icon-ruzhuchenggongdapx"></i> <span style="margin-left:0.3rem">到店时间</span></div>
						<div class="fui-list-inner bold r" ng-if="pagedata.post.tostoretime"><span style="color:red">预计</span>({{pagedata.post.tostoretime}} {{pagedata.post.tostorehour}}到店)</div>
						<div class="fui-list-inner bold r" ng-if="!pagedata.post.tostoretime">请选择到店时间</div>
						<div class="fui-list-angle"><div class="angle"></div></div>
					</div>
		 </div>
		 <div class="weui_cells">
		 <div ng-if="pagedata.post.type!=1 && false" class="weui_cell">
				   <div class="weui_cell_hd"><label class="weui_label">上门地址</label></div>
				   <div class="weui_cell_bd weui_cell_primary">
                     <input ng-model="pagedata.post.addressinfo.address" class="weui_input" type="text" placeholder="请输入地址">
				   </div>
				   <div class="weui_cell_ft" ng-click="tool.choose_location(pagedata.post,'addressinfo')"><i class="icon icon-ditu"></i></div>
		</div>
		<div ng-if="pagedata.post.type!=1 && false" class='fui-cellone' style="padding: 6px 2px;padding-bottom:0.5rem">
			<div class='fui-cellone-label' style="width:auto">预约时间</div>
			<div class="fui-cellone-info r">
				<select ng-model="pagedata.post.day" style="border: 0; outline: 0; background-color: #f9f9f9; font-size: inherit; padding: 0.2rem;">
					<option ng-repeat="(key,value) in pagedata.days" value="{{value}}">{{value}}</option>
				</select>
			</div>
			<div class="fui-cellone-remark noremark" style="margin-left:0.5rem">
				时间:
				<select ng-model="pagedata.post.time" style="border: 0; outline: 0; background-color: #f9f9f9; font-size: inherit; padding: 0.2rem;">
					<option ng-repeat="(key,value) in pagedata.times" value="{{value}}">{{value}}</option>
				</select>
			</div>
		</div>
		<div class="weui_cell">
                <div class="weui_cell_hd weui_cell_primary">
                    <span>服务费用</span>
                </div>
				<div class="weui_cell_ft">
				<span>{{pagedata.post.price || '0.00'}}元/次</span>
				</div>
        </div>
		</div>
		<div class="fui-navbar-tip" ng-if="pagedata.buyxieyi.isopen==1" style="height:1.8rem">
		<div class="fui-cellone sm" style="padding:0">
			<div class="fui-cellone-info" style='line-height:1.4;font-size:0.7rem'>
				<span class="text"><input type="checkbox" ng-checked="pagedata.post.checked==true" ng-model="pagedata.post.checked" name="checkbox" class="fui-radio fui-radio-danger cartmode check-item"/></span>
				<span class="text" ng-click="pagedata.show_xieyi=true;">请先阅读【{{pagedata.buyxieyi.title || '订单须知'}}】</span>
			</div>
		</div>
		</div>
		<div class="fui-navbar order-create-checkout">
			<a href="javascript:;" class="nav-item total" style="text-align:left;padding-left:0.5rem">
				<span  class="text-danger bigprice">&yen; 
					<span class="totalprice" style="font-size:1.2rem">{{price(pagedata.post.totalprice) || '0.00'}}</span>
				</span>
			</a>
			<a ng-if="!pagedata.order_id && pagedata.post.totalprice>0" href="javascript:;" class="nav-item btn btn-danger buybtn" ng-click="pagedata.pay_submit(pagedata.post,'jy_shoufrom/fuwu.book/post/','jy_shoufrom/fuwu.order//status=1')" >
				<div class="fee-tagup-nav">
					确认提交
				</div>
			</a>
			<a ng-if="pagedata.post.totalprice<=0" href="javascript:;" class="nav-item btn btn-danger buybtn" ng-click="post(pagedata.post,'jy_shoufrom/fuwu.book/post/')" >
				<div class="fee-tagup-nav">
					确认提交(到店支付)
				</div>
			</a>
			<a ng-if="pagedata.order_id" href="javascript:;" class="nav-item btn btn-danger buybtn" ng-click="access_json('jy_shoufrom/fuwu.order/')" >
				<div class="fee-tag-nav">
					查看订单
				</div>
			</a>
		</div>
</div>
</div>
<div ng-include="sys_html('shop/_selectstores','','','jy_weishop')"></div>
<div ng-if="pagedata.showtostoretime" class="popup">
		<style>
		.jyui_cell_col .red {
			background: red;
		}
		</style>
			<div class="popup-body">
			<div class="popup-bottom" style="border-radius:0.2rem;">
				<i class="closed icon icon-cuowu" ng-click="pagedata.showtostoretime=false"></i>
				<div class="fui-page-title" style="margin-top:1rem">选择要上门服务的时间！</div>
				<div class="fui-page-subtitle" style="margin-top:0.1rem">请在指定时间上门消费哦，不然可能门店没营业哦！</div>
				<div class="weui_cells_radio3">
					<div class="fui-icon-group noborder col-5">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_timedata" style="margin-top:0">
						<label class="jyui_cell_col">
							<div ng-if="item.iswork==1" ng-class="{'coltime colchecked':1,'red':pagedata.post.tostoretime==item.riqi}" ng-click="pagedata.post.tostoretime=item.riqi;pagedata.post.day=item.day">
								<div class="timetitle"><span>{{item.riqi}}</span></div>
								<div class="timetitle"><span>{{item.xinq}}</span></div>
							</div>
							<div ng-if="item.iswork!=1" class="coltime">
								<div class="timetitle"><span>{{item.riqi}}</span></div>
								<div class="timetitle"><span>{{item.xinq}}</span></div>
							</div>
						</label>
					</div>
					</div>
				</div>
				<div class="fui-cellone noborder">
					<div class="fui-cellone-label bold" style="width:auto;">上门时间段：</div>
					<div class="fui-cellone-info r">
					<select class="weui_select" name="cateid2" ng-model="pagedata.post.time">
                        <option ng-repeat="hour in pagedata.work_hours" ng-if="pagedata.nowtime<hour.timestamp || pagedata.nowmonthday!=pagedata.post.tostoretime" value="{{hour.start}}">{{hour.start}}</option>
					</select>
					</div>
				</div>
			</div>
			</div>
</div>
<div ng-if="pagedata.show_xieyi" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<i class="closed icon icon-cuowu" style="font-size:1.2rem;top:105%;" ng-click="pagedata.show_xieyi=false"></i>
			<div class="content-images" style="padding:0.5rem;height:20rem; overflow-y:scroll;">
					<div class="title bold" style="font-size:0.8rem">{{pagedata.buyxieyi.title||'订单须知'}} / <small>Read Ggree</small></div>
					<div class="text" style="padding-top:0.5rem;font-size:0.7rem" ng-bind-html="trust(pagedata.buyxieyi.content)">
					</div>
			</div>
			<div class="modal-footer">
				<div ng-click="pagedata.show_xieyi=false;pagedata.post.checked=true" class="mod-check" style="width: 100%; margin: 0;">我已阅读</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
scope.pagedata.post.serve_time=new Date(scope.pagedata.post.serve_time);
window.scope.location(function(res){
	scope.pagedata.getstores(res.lat_lng);
	scope.pagedata.post.address = res.address;
});
scope.pagedata.yuejie_select=function(yuejie_select){
	scope.pagedata.post.yuejie_select=yuejie_select;
	scope.pagedata.pay_submit(scope.pagedata.post,'jy_shoufrom/fuwu.book/post/','jy_shoufrom/fuwu.order//status=1');
}
scope.pagedata.pay_submit=function(post,post_url,complete_url){
	if(scope.pagedata.yuejiemid>0 && !scope.pagedata.post.yuejie_select){
		scope.pagedata.yuejie_show=true
		scope.$evalAsync();
		return false;
	}
	scope.post_json(post_url,post,function(result){
		if(result.order_id){
			scope.pagedata.order_id=result.order_id;
			scope.$evalAsync();
			scope.tool.pay(result.pay_id,function(res){
					if(res.type=='success'){
						scope.message('支付成功！','success',complete_url);
					}else{
						scope.message('支付失败！','success',complete_url);
					}
			},'','',complete_url,complete_url);
		}
	});
}
//刷新总数和总价
scope.pagedata.refresh=function(){
	var total=0,totalprice=0.00;
	totalprice=scope.pagedata.post.total*scope.pagedata.post.price
	totalprice = totalprice.toString(); //将数字转换为字符串
	var pos_decimal = totalprice.indexOf('.'); //小数点的索引值
	 // 当整数时，pos_decimal=-1 自动补0  
	if (pos_decimal < 0) {  
			pos_decimal = totalprice.length;  
			totalprice += '.';  
	}

	// 当数字的长度< 小数点索引+2时，补0  
	while (totalprice.length <= pos_decimal + 2) {  
			totalprice += '0';  
	}  
	scope.pagedata.post.totalprice=totalprice;
	scope.$evalAsync();
}
scope.pagedata.upprice=function(){
	var groupid=scope.pagedata.post.groupid
	var pid=scope.pagedata.post.pid
	scope.pagedata.post.nowitem=scope.pagedata.groups[groupid].list[pid];
	scope.pagedata.post.nowitem=scope.pagedata.post.nowitem?scope.pagedata.post.nowitem:{}
	scope.pagedata.post.diyfields=scope.pagedata.post.nowitem.diyfields;
	scope.pagedata.post.vip_price=scope.pagedata.post.nowitem.vip_price;
	scope.pagedata.post.price=scope.pagedata.post.nowitem.price;
	scope.pagedata.post.order_types=scope.pagedata.post.nowitem.order_types;
	scope.pagedata.post.totalprice=scope.pagedata.post.nowitem.price;
	if(scope.pagedata.pluginset.is_dianfee==1 && scope.pagedata.post.type==1){
		scope.pagedata.post.totalprice=0;
	}
	scope.pagedata.post.oldpid=scope.pagedata.post.pid;
	console.log(scope.pagedata.post);
	scope.$evalAsync();
}
scope.pagedata.getstores=function(lat_lng){
	scope.post_json('jy_weishop/get_data/getstores/',{'lat_lng':lat_lng},function(res){
			scope.pagedata.stores =res.stores
			scope.pagedata.stores_count =res.stores_count
			scope.$evalAsync();
	});
}
scope.pagedata.gotoshowstoretime=function(){
	scope.get('jy_weishop/store.index/get_work_time/store_id='+scope.pagedata.post.storeid,function(res){
		scope.pagedata.work_timedata=res.days;
		scope.pagedata.work_hours=res.hours;
		scope.pagedata.showtostoretime=true;
		res.hours[0]=res.hours[0]?res.hours[0]:{};
		scope.pagedata.post.time=res.hours[0].start
		scope.$evalAsync();
	});
}
scope.pagedata.selectstores=function(item){
	console.log('选择门店'+item.id);
	scope.pagedata.post.storeid = item.id;
	scope.pagedata.post.is_work_time = item.is_work_time;
	scope.pagedata.selectstore=item;
}
</script>